﻿import QtQuick 2.0

Item {
    property string title: "单选框"
    height: 40*dp
    id: root
    width: 160*dp

    property bool isChecked: false
    property bool editable: true

    signal released()

    Rectangle{
        x: 4*dp
        y: 12*dp
        height: 16*dp
        width: 16*dp
        radius: 8*dp
        border.color: "#CCCCCC"
        Rectangle{
            anchors.fill: parent
            radius: 8*dp
            color: editable ? "#1677FF" : "#CCCCCC"
            Rectangle{
                anchors.centerIn: parent
                color: "white"
                height: 8*dp
                width: 8*dp
                radius: 4*dp
            }
            visible: isChecked
        }
    }
    Item{
        height: 40*dp
        width: 40*dp
        x: 24*dp
        Text {
            font.pixelSize: config.fontsize
            anchors.verticalCenter: parent.verticalCenter
            text: title
        }
    }
    MouseArea{
        height: 30*dp
        width: parent.width
        cursorShape: Qt.PointingHandCursor
        y: 5*dp
        onReleased: {
            if(editable){
                root.focus = true
                root.released()
            }
        }
    }

}
